-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
me first a pull request #7
base: spokik-dev-events
Are you sure you want to change the base?
Conversation
В дальнейшем планирую разделить это все на модули. как вариант изучить webpac. Сейчас некоторые браузеры не поддерживают часть функций, (у одной девушки crome v49..._
собираются через функцию
@@ -5,9 +5,6 @@ import { windowForUserScript } from './modules/alert.js'; | |||
import { defaultMD } from './modules/autoMD.js'; | |||
|
|||
if (document.location.href === `https://kad.arbitr.ru/`) { windowForUserScript() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strings that contain url are better to be stored into const
kad.js
Outdated
@@ -5,9 +5,6 @@ import { windowForUserScript } from './modules/alert.js'; | |||
import { defaultMD } from './modules/autoMD.js'; | |||
|
|||
if (document.location.href === `https://kad.arbitr.ru/`) { windowForUserScript() } | |||
injectFunction(); | |||
|
|||
|
|||
|
|||
if (document.location.href != `https://kad.arbitr.ru/`) { | |||
let usersSettings = JSON.parse(localStorage.getItem(`usersSettings`)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to keep one pattern of quotes, single or double or backward. Usually, if you have just a string use the single quotes ''
modules/addBattons.js
Outdated
footer.innerHTML = `${xc} <div id="activeStat" class="tampleteButton" style="height:23px">Статистика</div>`; | ||
|
||
let classBlok = document.createElement("style") | ||
classBlok.innerHTML = "div.tampleteButton{height: 30px;width: 130px;-webkit-appearance: button;-webkit-writing-mode: horizontal-tb !important;color: buttontext;text-shadow: none;display: inline-block;text-align: center;align-items: flex-start;background-color: buttonface;box-sizing: border-box;margin: 0em;font: 400 13.3333px Arial;padding: 1px 6px;border-width: 2px;border-style: outset;border-color: buttonface;border-image: initial;}}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can separate html from css. Create a module css and [ut all the styling there ;) when you use everything together it is not possible to change in future when the project grows and it looks dirty, not readable.
modules/addBattons.js
Outdated
for (let index = 0; index < sostavs.length; index++) { | ||
let starArray = JSON.parse(localStorage.getItem(`sostav${sostavs[index]}`)) | ||
for (let key in starArray) { | ||
if (starArray[key].month == month) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try not to compare with ==
, use triple one ;)
modules/addBattons.js
Outdated
let today = new Date().getDate() | ||
let month = new Date().getMonth() + 1 | ||
let counter = {} | ||
for (let index = 0; index < sostavs.length; index++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you can replace this loop with the map
method :)
modules/addBattons.js
Outdated
} | ||
} | ||
//string stringify | ||
let stringReturn = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to use more descriptive and meaningful names. It's not clear what you mean by stringReturn, which string? what return? why xd?
modules/addBattons.js
Outdated
let stringReturn = '' | ||
for (let key in counter) { | ||
|
||
stringReturn = stringReturn + `${key} состав: ${counter[key]} штук | ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check if you can replace this loop just by that line:
const stringReturn = counter.map((key, index) => (
${index} состав: ${key} штук | ));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Угу, вот только counter = {}
return stringReturn | ||
} | ||
|
||
export { addBattons } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check please the spelling of the filename ;)
modules/addBattons.js
Outdated
let xc = sostavPerDay(usersSettings.usersSS) | ||
footer.innerHTML = `${xc} <div id="activeStat" class="tampleteButton" style="height:23px">Статистика</div>`; | ||
|
||
let classBlok = document.createElement("style") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
classBlok
looks weird tbh , doesn't it?
modules/addStaticOnLocalStorage.js
Outdated
let promise = new Promise((resolve, reject) => { | ||
let observer = new MutationObserver((mutationRecords) => { | ||
if (mutationRecords.length > 1) { | ||
let saveScanStat = document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload.b-popup--edit.js-popup--edit > form > div.b-popup-button.js-upload-submit"); // кнопка по которой срабатывает скрипт |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please try mot to shorten the names, not to be afraid of using long names. They are descriptive and takes less time to understand what's going on :)
modules/addStaticOnLocalStorage.js
Outdated
function addStaticOnLocalStorage() { | ||
let elem = document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload") | ||
|
||
let promise = new Promise((resolve, reject) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you don't use the parameter reject
, then you can add underscore before in order to avoid eslint error/warn .
And if you do not change the variable in code use const instead
@@ -1,17 +1,17 @@ | |||
# Kad.arbitr | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here should be instructions how to run your application in Readme
Scan
Outdated
document.getElementsByClassName(`b-popup-sj-link js-popup-sj-link js-popup-sj-link--upload`)[0].onclick = () =>{document.getElementsByClassName('js-input js-input--combobox js-input--deselect_with_save_val')[1].value = `Материалы по делу`;} | ||
(function () { | ||
"use strict"; | ||
let usersSettings = JSON.parse(localStorage.getItem(`usersSettings`)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use const if you don't assign a new value ;)
@@ -88,7 +90,7 @@ function addStaticOnLocalStorage() { | |||
function sostavAtPopup(sostav) { | |||
const elem = document.createElement("div") | |||
elem.className = "b-popup-info" | |||
elem.innerHTML = `<div class="b-popup-info-title">Состав</div><span class="b-popup-info-text js-popup-info-text" title="${sostav}">${sostav}</span>` | |||
elem.innerHTML = `<div class="b-popup-info-title" id="userSS">Состав</div><span class="b-popup-info-text js-popup-info-text" title="${sostav}">${sostav}</span>` | |||
let isYourSostav = false | |||
function isCorrectSostav() { | |||
for (let i = 0; i < usersSettings.usersSS.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the content of this loop can be written just in one line with the help of the ternary operation:
for (let i = 0; i < usersSettings.usersSS.length; i++) { return (isYourSostav = usersSettings.usersSS[i] == sostav ? true : false); }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and also below состав неопределен
is it should be necessary the phrase with space before??
modules/addStaticOnLocalStorage.js
Outdated
|
||
//Срабатывает прии НАЖАТИИ на "Сохранить" | ||
params.saveScanStat.onclick = () => { | ||
let now = new Date() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please change the name to currentDate
for example :)
modules/addStaticOnLocalStorage.js
Outdated
let now = new Date() | ||
let dataForLS = {} | ||
dataForLS = JSON.parse(localStorage.getItem(`sostav${params.sostav}`)) | ||
if (dataForLS == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can reverse this logic of checking :)
check for existence ;)
const dataForLS = JSON.parse(localStorage.getItem(
sostav${params.sostav}));
and then if (dataForLS !==null)
modules/addStaticOnLocalStorage.js
Outdated
let observer = new MutationObserver((mutationRecords) => { | ||
if (mutationRecords.length > 1) { | ||
let saveScanStat = document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload.b-popup--edit.js-popup--edit > form > div.b-popup-button.js-upload-submit"); // кнопка по которой срабатывает скрипт | ||
let q = document.querySelector("#chrono_list_content > div.b-chrono-items-container.js-chrono-items-container > div").childElementCount //Кол-во элементов для фикла |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use such short names for large functions or classes, where another context gives you the entire impression, but here it's tricky to understand
modules/addStaticOnLocalStorage.js
Outdated
let params = { | ||
saveScanStat: saveScanStat, | ||
sostav: sostav, | ||
docId: docId, | ||
a40: a40, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you use the same names of the props and values , then you don't need to write it twice ;)
let params = { saveScanStat, sostav, docId, a40,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я собственно так и сделал недавно, правда в другой ветке
modules/addStaticOnLocalStorage.js
Outdated
.trim() //Удаляет пробелы "с краёв" | ||
.split(` `) //Правращает в масив по разделителю " " | ||
let stringValueCounter = 0 | ||
if (stringValueCounter < 2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and what if stringValueCounter
is equal to 2 ?
I recommend you to change if-else implementation here, it's confusing and long
@@ -1,57 +1,57 @@ | |||
// Добавляет обработчики интерфейса | |||
function addTamplaties() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name :)
@@ -0,0 +1,57 @@ | |||
// Добавляет обработчики интерфейса |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should apply VS formatter here. It's unreadable at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modules/checkReload.js
Outdated
if (lastFilles === undefined) { | ||
lastFilles = {} | ||
return lastFilles | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you assign an empty object?
you can check the value to exist and proceed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я уже не помню, оно без этого не работало XD
modules/statisticsInterface.js
Outdated
let classBlok = document.createElement("style") | ||
classBlok.innerHTML = ` | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
background: #f3f3f3; | ||
} | ||
.settings { | ||
position: absolute; | ||
left: 82%; | ||
top: 40px; | ||
width: 250px; | ||
border: 1px solid rgb(205 205 224); | ||
padding: 5px; | ||
color: rgb(255 255 255); | ||
background: rgb(50 50 51); | ||
display: block; | ||
} | ||
#word_opts { | ||
position: relative; | ||
padding: 4px; | ||
width: 60px; | ||
height: 60px; | ||
background: #c6c6c6; | ||
outline: none; | ||
border-radius: 7px; | ||
box-shadow: inset 0 0 5px rgba(0,0,0, .2); | ||
transition: 0.5s; | ||
} | ||
|
||
label input[type="checkbox"]:checked + #word_opts { | ||
background: #02a9f4; | ||
} | ||
|
||
input[type="checkbox"] { | ||
width: 40px; | ||
height: 20px; | ||
-webkit-appearance: none; | ||
-moz-appearance: none; | ||
background: #c6c6c6; | ||
outline: none; | ||
border-radius: 50px; | ||
box-shadow: inset 0 0 5px rgba(0,0,0, .2); | ||
transition: 0.5s; | ||
position: absolute; | ||
right: 40px; | ||
} | ||
input:checked[type="checkbox"] { | ||
background: #02a9f4; | ||
} | ||
input[type="checkbox"]::before { | ||
content: ''; | ||
position: absolute; | ||
width: 20px; | ||
height: 20px; | ||
border-radius: 50%; | ||
top: 0; | ||
left: 0; | ||
background: #fff; | ||
transform: scale(1.1); | ||
box-shadow: 0 2px 5px rgba(0,0,0, .2); | ||
transition: 0.5s; | ||
} | ||
input:checked[type="checkbox"]::before { | ||
left: 20px; | ||
} | ||
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to extract all the css to the css module :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I will be try
modules/alert.js
Outdated
if (year20 == true) { year = 20; } | ||
else if (year19 == true) { year = 19; } | ||
else if (year18 == true) { year = 18; } | ||
else { alert(`ЕРОР! Чет какая - то шляпа введина в место года`) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use ternary operators here
modules/alert.js
Outdated
//пересобирает строку, заменя 2 последний цифры | ||
function setYear(year) { | ||
let newNumber = document.querySelector(`#sug - cases.tag input[type = "text"]: valid`).value | ||
let inString = document.querySelector(`#sug - cases.tag input[type = "text"]: valid`).value["length"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't like the name XD
modules/alert.js
Outdated
} | ||
|
||
|
||
//Красим фон и меняем год |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you use comments, it means you use bad names ;)
modules/statisticsInterface.js
Outdated
for (let i = 0; i < document.querySelectorAll("#settings > input[type=checkbox]").length; i++) { | ||
let x = document.querySelectorAll("#settings > input[type=checkbox]")[i] | ||
if (x.checked) { | ||
preSet[x.name] = "checked" | ||
} else { | ||
preSet[x.name] = "" | ||
} | ||
|
||
localStorage.setItem(`usersSettings`, JSON.stringify(preSet)) | ||
}) | ||
} | ||
preSet.usersSS = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too long, i believe you can reduce it with the help of methods of js and ternary operators ;)
@@ -1,13 +1,13 @@ | |||
const usersSettings = JSON.parse(localStorage.getItem(`usersSettings`)) | |||
if (usersSettings == undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!usersSettings)
…пределен. не тестилось
Давно не занимался проектом, не помню где ошибки. Не хочу разбираться. Кажется более простым вариантом вернуться к рабочей версии и плясать от нее
No description provided.